<?php
// 登录

// 引入 数据库工具
require_once("DButil.php");

$loginName = $_REQUEST["loginName"];
$pwd = $_REQUEST["pwd"];

$sql = "select teacherId,teacherName,username,status,roleId from t_teacher where username='$loginName' and password='$pwd'";
$result = queryOne(getConn(), $sql);

// json 数据格式
$arr = [
    "success" => false,
    "msg" => "用户名或密码错误",
    "data" => null
];
if($result["data"]){
    // 保存登录的teacher信息
    $_SESSION["login"] = $result["data"];
    $arr = [
        "success" => true,
        "msg" => "登录成功",
        "data" => $result["data"]
    ];
}
header("Access-Control-Allow-Origin:*");
header("Content-Type:application/json;charset=UTF-8");
echo json_encode($arr);
?>